package org.dxy.domain.model.valueobject;

/**
 * 物料状态值对象
 * @author dxy
 * @createTime 2025/9/7
 */
public record MaterialStatus(String value) {
    
    public static final String ACTIVE = "ACTIVE";
    public static final String DISABLED = "DISABLED";
    public static final String DELETED = "DELETED";
    
    public MaterialStatus {
        if (value == null || value.trim().isEmpty()) {
            throw new IllegalArgumentException("物料状态不能为空");
        }
        if (!isValidStatus(value)) {
            throw new IllegalArgumentException("无效的物料状态: " + value);
        }
    }
    
    public static MaterialStatus active() {
        return new MaterialStatus(ACTIVE);
    }
    
    public static MaterialStatus disabled() {
        return new MaterialStatus(DISABLED);
    }
    
    public static MaterialStatus deleted() {
        return new MaterialStatus(DELETED);
    }
    
    public boolean isActive() {
        return ACTIVE.equals(value);
    }
    
    public boolean isDisabled() {
        return DISABLED.equals(value);
    }
    
    public boolean isDeleted() {
        return DELETED.equals(value);
    }
    
    private static boolean isValidStatus(String status) {
        return ACTIVE.equals(status) || DISABLED.equals(status) || DELETED.equals(status);
    }
}